const { getproduct, addproduct, renoveone, getupdataproductID, updataproduct, search, getgoods,show } = require('../../Dao/store/storeDao');
//获取所有商品
module.exports.getproduct = async function (data) {
 // var { searchoose, select, pagesize, currentPage } = data
  // if (searchoose, select) {
  //   var data = await search(searchoose, select)
  //   return data
  // } else {
  //   var data = await getproduct(pagesize, currentPage)
  //   return data
  // }
  return await getproduct(data);
   
}
module.exports.addproduct = async function (data) {
  var datas = await addproduct(data)
  if (datas._id) {
    return {
      msg: "新增成功"
    }
  } else {
    return {
      msg: "新增失败"

    }
  }

}
module.exports.renoveone = async function (data) {
  var datas = await renoveone(data)
 // console.info("2层返回", datas)
  if (datas.n > 0 && datas.ok > 0) {
    return true
  } else {
    return false 
  }

}
module.exports.getupdataproductID = async function (data) {
  var datas = await getupdataproductID(data)
  return datas
}
module.exports.updataproduct = async function (data) {
  var datas = await updataproduct(data)
  if (datas.n == 1 && datas.ok == 1) {
    return {
      msg: "修改成功",
      success: true
    }
  } else {
    return {
      msg: "修改失败",
      success: false
    }
  }
}

module.exports.getgoods = async function () {
  var data = await getgoods()
  return data

}
module.exports.show = async function (datas) {
  var data = await show(datas)
  console.info("fabhui纯爱",data)
  if (datas._id) {
    return {
      msg: "上传商品成功",
    }
  } else {
    return {
      msg: "上传商品失败"

    }

  }
}